<?php

  define('BASE_ROOT_PATH', dirname(dirname(__FILE__)));
	include_once( BASE_ROOT_PATH . "/word/db/DBMySQL.php");  

	$memberId = $_REQUEST['id'];
	if(empty($memberId)) {
	  $msg = json_encode("用户id不能为空");
		echo '{"code":"1","msg":'.$msg.'}';
		exit();
	}

	$gender = $_REQUEST['gender'];
	if(empty($gender)) {
	  $gender = '';
	}
	$gender = str_replace('\'', '\'\'', $gender);
	
	$exam = $_REQUEST['exam'];
	if(!isset($exam)) {
	  $exam = '-1';
	}	
	$exam = str_replace('\'', '\'\'', $exam);	
	//用户年龄
	$year = $_REQUEST['year'];
	if(empty($year)) {
	  $year = '';
	}	
	$year = str_replace('\'', '\'\'', $year);

	//国家
	$country = $_REQUEST['country'];
	if(empty($country)) {
	  $country = '';
	}	
	$country = str_replace('\'', '\'\'', $country);
	//城市信息
	$city = $_REQUEST['city'];
	if(empty($city)) {
	  $city = '';
	}	
	$city = str_replace('\'', '\'\'', $city);
	
	//Looking For
	$dreamSchool = $_REQUEST['dreamSchool'];
	if(empty($dreamSchool)) {
	  $dreamSchool = '';
	}	
	$dreamSchool = str_replace('\'', '\'\'', $dreamSchool);
	
	//状态
	$status = $_REQUEST['status'];
	if(empty($status)) {
	  $status = '';
	}	
	$status = str_replace('\'', '\'\'', $status);
	
	//状态
	$applyYear = $_REQUEST['applyYear'];
	if(empty($applyYear)) {
	  $applyYear = '';
	}	
	$applyYear = str_replace('\'', '\'\'', $applyYear);

	//教师Section
	$section = $_REQUEST['section'];
	if(empty($section)) {
	  $section = '';
	}	
	$section = str_replace('\'', '\'\'', $section);		

	//GMAT专业
	$major = $_REQUEST['major'];
	if(empty($major)) {
		$major = '';
	}
	$major = str_replace('\'', '\'\'', $major);
		
	$isteacher = $_REQUEST['isteacher'];
	if (!isset($isteacher)) {
		$isteacher = 0;
	}
	
	// 查找用户
	$db = new DBMySQL();
	$rs = $db->Query("select mi.member_id,m.email from t_member m join t_member_info mi on mi.member_id = m.member_id where m.member_id = $memberId limit 1");
	if(empty($rs)) {
	  $msg = json_encode("该用户不存在");
		echo '{"code":"1","msg":'.$msg.'}';
		exit();
	}
	$val = $rs[0];
	$memberId = $val['member_id'];
	$db->Modify("update t_member_info mi set mi.gender='$gender',mi.exam='$exam',mi.section='$section',mi.apply_year='$applyYear',mi.year='$year',mi.country='$country',mi.city='$city',mi.dream_school='$dreamSchool',mi.status='$status',mi.major='$major' where mi.member_id = $memberId");	
	$db->Modify("update t_member m set m.isteacher=$isteacher where m.member_id = $memberId");
	echo '{"code":"0","msg":""}';
	
?>